/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CashPaymentPanel.java
 *
 * Created on Feb 22, 2011, 12:15:34 PM
 */

package POSTApp;
import Payment.Payment;
import Payment.CashPayment;

/**
 * GUI panel for processing cash payments.
 * @author Rebecca Bettencourt
 */
public class CashPaymentPanel extends PaymentPanel {

    /** Creates new form CashPaymentPanel */
    public CashPaymentPanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cashLabel = new javax.swing.JLabel();
        cashAmount = new javax.swing.JTextField();

        cashLabel.setText("Amount Given:");

        cashAmount.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cashAmountActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(cashLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cashAmount, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                .add(cashLabel)
                .add(cashAmount, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cashAmountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cashAmountActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cashAmountActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField cashAmount;
    private javax.swing.JLabel cashLabel;
    // End of variables declaration//GEN-END:variables

    public Payment getPayment(float total) {
        return new CashPayment(total, Float.parseFloat(cashAmount.getText()));
    }

    public void clearPayment() {
        cashAmount.setText("");
    }
}
